package com.test.service.impl;

import java.util.List;

import com.test.dao.IEmployeeDao;
import com.test.dao.impl.EmployeeDaoImpl;
import com.test.enity.Employee;
import com.test.service.IEmployeeService;

//业务逻辑层
public class EmployeeServiceImpl implements IEmployeeService{

	IEmployeeDao employeeDao = new EmployeeDaoImpl();

	public boolean addEmployee(Employee employee) {
		if (!employeeDao.isExist(employee.getId())) {
			employeeDao.addEmployee(employee);
			return true;
		} else {
			System.out.println("此人已存在！！！");
			return false;
		}
	}

	public boolean deleteEmployee(int eid) {
		if (employeeDao.isExist(eid)) {
			return employeeDao.deleteEmployeeByEid(eid);
		}
		return false;
	}

	public boolean updateEmployee(int eid, Employee employee) {
		if (employeeDao.isExist(eid)) {
			return employeeDao.updateEmployeeByEid(eid, employee);
		}
		return false;
	}

	public Employee queryEmployeeByID(int eid) {
		return employeeDao.queryEmployeeByEid(eid);
	}

	public List<Employee> queryAllEmployees() {
		return employeeDao.queryAllEmployee();
	}
}
